<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    const IS_SHOW = 1;  //显示
    const IS_HIDE = 0;  //否
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'pid', 'source', 'editor','thump','description','content','is_index','tips'
    ];
    /**
     * 插入时间戳
     */
//    protected function getDateFormat(){
//        return time();
//    }
    /**
     * 返回时间戳
     */
//    protected function asDateTime($val){
//        return $val;
//    }
    public function getIsShow( $key = null ){
        $array = [
            self::IS_SHOW => '是',
            self::IS_HIDE => '否,'
        ];
        if( $key !== null ){
            return array_key_exists($key,$array) ? $array[$key] : $array[self::IS_HIDE];
        }
        return $array;
    }

}
